package com.ysd.lis.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ysd.common.Result;
import com.ysd.lis.entity.WkEmployeeProfessional;
import com.ysd.lis.mapper.WkEmployeeProfessionalMapper;
import com.ysd.lis.service.WkEmployeeProfessionalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 员工档案-职称表 服务实现类
 * </p>
 *
 * @author LiuQi
 * @since 2024-02-22
 */
@Service
public class WkEmployeeProfessionalServiceImpl extends ServiceImpl<WkEmployeeProfessionalMapper, WkEmployeeProfessional> implements WkEmployeeProfessionalService {

    @Autowired
    WkEmployeeProfessionalMapper wkEmployeeProfessionalMapper;

    @Override
    public Result getEmployeeProfessionalList(String wkEmployeeId) {
        LambdaQueryWrapper<WkEmployeeProfessional> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(WkEmployeeProfessional::getDelFlag, 0)
                .eq(WkEmployeeProfessional::getWkEmpId, wkEmployeeId);
        List<WkEmployeeProfessional> wkEmployees = wkEmployeeProfessionalMapper.selectList(lambdaQueryWrapper);
        return Result.succ(1, "查询成功！", wkEmployees);
    }

    @Override
    public Result addEmployeeProfessional(WkEmployeeProfessional wkEmployeeProfessional) {
        boolean save = this.save(wkEmployeeProfessional);
        if (save) {
            return Result.succ(1, "添加成功", null);
        } else {
            return Result.fail("添加失败");
        }
    }

    @Override
    public Result updateEmployeeProfessional(WkEmployeeProfessional wkEmployeeProfessional) {
        boolean save = this.updateById(wkEmployeeProfessional);
        if (save) {
            return Result.succ(1, "编辑成功", null);
        } else {
            return Result.fail("编辑失败");
        }
    }

    @Override
    public Result deleteEmployeeProfessional(WkEmployeeProfessional wkEmployeeProfessional) {
        boolean b = this.removeById(wkEmployeeProfessional.getId());
        if (b) {
            return Result.succ(1, "删除成功", null);
        } else {
            return Result.fail("删除失败");
        }
    }
}
